home *** CD-ROM | disk | FTP | other *** search
- Path: in2.uu.net!saix!usenet
- From: Tiaan Wessels <tiaan>
- Newsgroups: comp.lang.c++
- Subject: (no subject)
- Date: 31 Jan 1996 12:21:12 GMT
- Organization: The South African Internet Exchange.
- Message-ID: <4enmro$kac@igubu.saix.net>
- NNTP-Posting-Host: tiaan.inetsys.alt.za
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.1N (X11; I; Linux 1.1.88 i486)
- X-URL: news:comp.lang.c++
-
- I have a problem with overloading the << operator and would like some help
-
- Th following code does not compile. Why ?
-
- #include <iostream.h>
-
- class Base
- {
- public:
- Base() {}
-
- virtual ostream &operator << ( ostream & ) {}
- };
-
- class Child : public Base
- {
- int mine;
- public:
- Child( int a ) { mine = a; }
-
- virtual ostream &operator << ( ostream &strm )
- {
- strm << mine;
- return strm;
- }
- };
-
- void main()
- {
- Child c( 5 );
- cout << c;
- }
-
- I'd appreciate any help.
- --
- Tiaan Wessels
- tiaan@inetsys.alt.za
- Netsys International
-
-